/* Sorting an array
   of random nubers
   Bubble sort */

#include <iostream>
#include <cstdlib>

int main()
{
    int nums[10];
    int size = 10;

    std::cout << "Random array" << std::endl;
    for (int i=0; i<size; i++){
        nums[i] = rand();
        std::cout << nums[i] << ' ';
    }
    std::cout << std::endl;

    for (int l=1; l<size; l++)             // Bubble sort
        for (int r=size-1; r>=l; r--){
            if (nums[r-1] > nums[r]){
                int t = nums[r-1];
                nums[r-1] = nums[r];
                nums[r] = t;
            }
        }

    std::cout << "Sort array" << std::endl;
    for (int i=0; i<size; i++)
        std::cout << nums[i] << ' ';

    return 0;

}
